1. Field of the Invention
The present invention relates to a peripheral device such as a printer or scanner capable of communicating with a host device, and to a control method for the peripheral device.
2. Description of the Related Art
The Universal Serial Bus (simply referred to as xe2x80x9cUSBxe2x80x9d below) is an interface for connecting and enabling the exchange of user and control data between peripheral devices, such as printers and scanners, and a host such as a personal computer. It is rapidly becoming the standard interface for connecting such peripheral devices (sometimes called xe2x80x9cdevice(s)xe2x80x9d below) to a personal computer (simply called xe2x80x9cPCxe2x80x9d below).
More specifically, USB is a bus standard for a serial cable connection enabling a PC to simultaneously access numerous devices with high data reliability while also enabling xe2x80x9chot swappingxe2x80x9d, the ability to insert and remove devices on the USB chain while the host and/or other devices are operating without losing access to the devices that remain on the bus. Because of this combination of high data reliability and hot swapability, USB is expected to become the industry-standard interface for PC peripheral connections.
Data transmission between USB interface devices begins when the host sends a token packet to a device. To enable simultaneous access to a plurality of devices, the token packet contains a unique device address and device endpoint. The address identifies which device on the USB is being addressed, and the endpoint identifies the source of the data or data transfer, or the data recipient or consumer (sink). Following the token packet comes a data packet containing the data being communicated, and a handshake packet indicating the transfer status.
USB uses the following four data transfer types, and transfers data by establishing a corresponding logical xe2x80x9cpipexe2x80x9d between the host and device.
Bulk transfers, and the bulk transfer pipe, are used for sending relatively large amounts of data, such as print and display data.
Interrupt transfers, and the interrupt transfer pipe, are used for small amounts of data with a short service period.
Control transfers, and the control transfer pipe, are used when a device is first connected to the bus to construct a logical device presence.
Isochronous transfers, and the isochronous transfer pipe, are used for audio and other types of data requiring data to be delivered within certain time constraints.
Sending a data stream in any of these transfer modes is called a xe2x80x9ctransaction,xe2x80x9d and comprises the above-described packet sequence.
Frames sent at 1 ms intervals contain a plurality of transactions. Simultaneous communication between a host and multiple devices is achieved by sending these frames in succession.
The handshake packet provides a retry function in case an error occurs during transmission, thereby enabling large amounts of data to be reliably transferred at high speed.
When the USB device communicating with the host is a printer, for example, data communicated between the host and the printer includes status information indicating the operating status of the printer, in addition to process data such as bitmap data or other print data and control commands for controlling the printing mechanism. Typical status information includes the on-line or off-line status of the printer, whether there is paper, whether the cover is open, if the buffer is full, whether there is ink, and any error status. The status information is normally sent from the printer to the host in response to a status request command, and is therefore sent to the host using the same bulk transfer type that is used to send print and command data from the host to the printer.
A USB bulk transfer pipe is only opened, however, when the bus capacity (bandwidth) needed to transfer the data within a specific unit time is available; therefore there is no way to assure when the data will be sent. This means that information may not be transferred immediately when status information is transferred using a bulk transfer pipe, and various problems can result. For example, the host may continue sending process data even though the buffer is full, and data may therefore be lost. The host may also continue sending data even though the printer cover is open, and printing delays may thus occur.
The interrupt transfer pipe, on the other hand, is opened at regular short intervals, enabling a device to send data to the host immediately if there is data to send when the device is polled. The interrupt transfer pipe is thus assured the highest level of service, providing good real-time performance. Data reliability is also extremely high because the transfer is retried at the next period if a bus error occurs and a transaction is lost. It is therefore possible to send status information using the interrupt transfer type, and thereby assure both immediacy and data reliability.
However, the size of the data packets that can be sent by interrupt transfer is limited in order to assure bandwidth availability. It is also preferable to release bandwidth for bulk transfers in order to maintain an acceptable transfer speed for process data. As a result, it is also desirable to limit data transfers using the interrupt transfer pipe.
An object of the present invention is therefore to provide a peripheral device and a control method therefor whereby the immediacy of status information transfers can be assured, bandwidth sufficient for efficient transfer of process data and commands can be assured, and a high data transfer rate can be assured.
To achieve the above object, a peripheral device according to the present invention assures immediate, real-time response while maximizing bandwidth available for bulk transfers by selectively transferring status information using a bulk transfer pipe or an interrupt transfer pipe according to the type of status information rather than simply sending all status information by either bulk transfer or interrupt transfer pipe.
More specifically, a peripheral device according to the present invention comprises a transmission unit for exchanging data with a host and for sending to the host status information indicative of an operating condition of the peripheral device. The transmission unit has an interface for sending data to and receiving data from the host. The interface can send and receive data by at least two transfer modes. A first transfer mode corresponds to the bulk transfer type of the USB interface, that is, a transfer mode in which data sending and receiving are enabled based on an input/output command sent from the host when transfer time has been reserved. A second transfer mode corresponds to the interrupt transfer type of the USB interface, that is, a transfer mode in which data sending and receiving are enabled based on an input/output command sent at a regular interval from the host. The status transmission unit has a first transfer function for sending status information by the first transfer mode, a second transfer function for sending status information by the second transfer mode, and a selecting function for selecting the first or second transfer function according to the cause for sending the status information.
A peripheral device control method according to the present invention is also provided. Status information indicative of an operating condition of the peripheral device is detected in a detecting step. In a selecting step, a first or second transfer mode is selected according to the cause for sending status information to a host. In the first transfer mode, data sending and receiving are enabled in response to an input/output command sent from the host when transfer time has been reserved. In the second transfer mode, data sending and receiving are enabled in response to an input/output command sent at a regular interval from the host. A first transfer step sends status information to the host by means of the first transfer mode if that mode is selected in the selecting step, and a second transfer step sends status information to the host by means of the second transfer mode if that mode is selected in the selecting step.
This peripheral device control method may be provided as a control program of instructions recorded on a device readable medium where the control program includes instructions or commands for execution by the peripheral device to perform the steps of the control method.
A peripheral device and peripheral device control method according to the present invention can thus send status information in response to a request from the host using the first transfer function or first status transfer step, and can send autonomously generated status information by the second transfer function or second status transfer step. As a result, status information requiring immediate communication can be sent immediately by the second transfer function, and status information not requiring immediate communication can be sent by the first transfer function.
More specifically, most cases in which status information is sent in response to a request from the host are cases in which the next process is executed after the requested status information is confirmed by the host, and immediate response is not as necessary. Furthermore, when the requested status information is urgently required, the host knows that the status information is urgent, and can therefore obtain the required status information at the appropriate timing using the first transfer mode such as a bulk transfer pipe in the case of the USB.
On the other hand, the host does not know when status information is autonomously generated by the peripheral device, and this autonomous status information is therefore urgent. The urgency and timely transfer of such autonomous status information can be assured in this case by sending it to the host using the second transfer mode such as an interrupt transfer pipe in the case of the USB.
When status information is thus communicated through an interface using at least two different transfer pipes, as does the USB, a peripheral device and peripheral device control method according to the present invention transfers only status information of the greatest urgency (immediacy) using the second transfer mode, that is, the transfer mode having the shortest service period (such as the USB interrupt transfer pipe), and uses the first transfer mode (such as the USB bulk transfer pipe) to send status information in all other cases.
It is therefore possible to transfer status information using a transfer mode appropriate to the immediacy of the information, thereby transferring status information without occupying unnecessary USB bandwidth, and thus assuring sufficient transmission speed for process data using a bulk transfer pipe.
It is therefore possible to sufficiently assure the immediacy of status information without impairing the performance of a peripheral device having a processing mechanism such as a printing mechanism or reading mechanism for outputting data to or inputting data from an external source, and a controller for sending or receiving process data processed by this processing mechanism by the first transfer mode.
Other objects and attainments together with a fuller understanding of the invention will become apparent and appreciated by referring to the following description and claims taken in conjunction with the accompanying drawings.